<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
    <div id="app"></div>
</body>
<script>
    let vm = {
        data () {
            return {

            }
        },
        template: `<input v-focus="1" />`
    }
    const app = Vue.createApp(vm)
    // 添加自定义指令 v-focus
    app.directive('focus', {
        mounted (el, bind) {
            // 输出节点
            console.log(el);
            // 令input框自动获取焦点状态
            el.focus()
            // bind.value可以获取focus的值
            console.log(bind.value);
        }
    })
    app.mount('#app')
</script>

</html>